/**
 * 
 */
package neptune.web.server.model;

import it.robertobifulco.ias.principalmanager.Principal;
import neptune.manager.IsUser;

/**
 * Incapsula le informazioni necessarie a gestire gli utenti e fa da collante
 * fra i Principal definiti nell'IAS e gli User definiti in NeputneManager Lib.
 * 
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class ApplicationUser extends Principal implements IsUser {
	
	public static String UNDEFINED_VALUE = "UNDEFINED";
	
	private String password;
	private String email;

	public ApplicationUser(boolean authenticated, String role, String id) {
		super(authenticated, role, id);
	}

	public ApplicationUser(Principal principal, String password){
		super(false, principal.getRole(), principal.getId());
		this.password = password;
	}
	
	public ApplicationUser(IsUser user, String role, String password){
		super(false, role, user.getUsername());
		this.password = password;
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see neptune.manager.IsUser#getUsername()
	 */
	public String getUsername() {
		return this.getId();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see neptune.manager.IsUser#setUsername(java.lang.String)
	 */
	public void setUsername(String username) {
		this.setId(username);
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		ApplicationUser appUsr = (ApplicationUser)obj;
		if(appUsr.getId().equals(this.getId()))
			return true;
		return false;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "ApplicationUser{" + this.getId() + ":" + this.getRole() + "}";
	}

	/**
	 * 
	 * @return
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	
}
